import Vue from 'vue'
import Router from 'vue-router'
const index = r => require.ensure([], () => r(require('../pages/index/index.vue')), 'index')
const other = r => require.ensure([], () => r(require('../pages/other/index.vue')), 'other')
const login = r => require.ensure([], () => r(require('../pages/login/index.vue')), 'login')
const newBorrower = r => require.ensure([], () => r(require('../pages/add-borrower/index.vue')), 'newBorrower')
const loanDetail = r => require.ensure([], () => r(require('../pages/loan-detail/index.vue')), 'loanDetail')
const FieldDiary = r => require.ensure([], () => r(require('../pages/field-diary/index.vue')), 'FieldDiary')

Vue.use(Router)

const router = new Router({
  routes: [{
      path: '/',
      redirect: '/home'
    },
    {
      path: '/home',
      name: '首页',
      meta: {
        title: '首页'
      },
      component: index
    },
    {
      path: '/login',
      name: 'login',
      meta: {
        title: '登陆'
      },
      component: login
    },
    {
      path: '/new',
      name: '新借款人',
      meta: {
        title: '新借款人'
      },
      component: newBorrower
    },
    {
      path: '/loan-detail',
      name: '借款人信息',
      meta: {
        title: '借款人信息'
      },
      component: loanDetail
    },
    {
      path: '/field-Diary',
      name: '现场日记',
      meta: {
        title: '现场日记'
      },
      component: FieldDiary
    },
    {
      path: '/other',
      name: 'other',
      meta: {
        title: 'other'
      },
      component: other
    }
  ]
})
router.beforeEach(function (to, from, next) {
  document.title = to.meta.title
  next()
})

export default router
